package com.cn.wanxi.servlet;

import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.model.NavModel;
import com.cn.wanxi.service.INavService;
import com.cn.wanxi.service.impl.CompanyService;
import com.cn.wanxi.service.impl.NavServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/home")
public class HomeServlet extends HttpServlet {
    /**
     * 1.servlet生命周期
     * 2.doget和dopost的区别
     * Java  三层架构
     * 页面控制层 servlet服务逻辑层 service 数据实现层dao
     * 三层架构和MVC的区别？
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


        CompanyService companyService = new CompanyService();
        CompanyModel companyModel = companyService.getCompanyModel();
        req.setAttribute("companyModel", companyModel);//key-value
        /**
         * jsp的九大内置对象
         * jsp的四大作用域
         * req，session，application，pageContent
         * 页面转发和重定向的区别？
         */
        INavService navService = new NavServiceImpl();
        List<NavModel> navlist = navService.getNavModelList();
        req.setAttribute("navList", navlist);
//
//        ProductService productService = new ProductService();
//        List<ProductModel> productModelList = productService.getProductModelList();
//        req.setAttribute("productModelList", productModelList);
//
//
//        NewsService newsService = new NewsService();
//        List<NewsModel> newsModelList = newsService.getNewsModelList();
//        req.setAttribute("newsModelList", newsModelList);
        req.getRequestDispatcher("/jsp/home.jsp").forward(req, resp);

    }
    /**
     * 1.Java数据类型
     * 2.类  面向对象  封装
     * 3.分层
     * 4.权限修饰符
     * 5.几个注意的面试笔试问题
     * 6.jsp页面引用
     * 7.赋值${companyModel.logo}
     *
     * web.xml  入口-----------》指向servlet页面控制层的webservlet注解
     * ------------》封装公司数据到request作用域对象-------------》返回页面
     *
     */
}
